#ifndef REGIONLISTCTR_H_INCLUDED
#define REGIONLISTCTR_H_INCLUDED

#include <array>

#include <wx/listctrl.h>

#include "RegionManager.h"

class RegionEditDlg;

class RegionListCtrl: public wxListCtrl
{
public:
    RegionListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos,
        const wxSize& size, long style,const wxValidator& validator,
        const wxString& name);

    inline RegionManager & GetRegionManager() {return m_regionManager;}

    void Load(const wxString & fileName, const wxString & filter);

    void Reload(const wxString & filter);

    void FitColumn();

    wxString GetItemText(long index, long column) const;

    int UpdateItemText(long index, long column,
        const wxString & text);

    bool Edit(long index);

    bool CreateRegion();

    RegionManager * GetManager() {return &m_regionManager;}

private:

    int AddRegion(const Region & region);

    void Load(const vector<Region> & regionList);

    int SetItemTextAndData(long index, long column, const wxString & text, long data);

    long GetItemData(long index, long column);

public:
    static const long ID_REGION_EDIT_DLG;
    static const long ID_REGION_CREATE_DLG;

private:
    vector<array<long, 10> > m_itemData;
    RegionManager m_regionManager;
    bool m_loaded = false;
    RegionEditDlg * m_regionEditDlg;
    RegionEditDlg * m_regionCreateDlg;
};

#endif // REGIONLISTCTR_H_INCLUDED
